<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/public/header.jsp"%>
<%
    String callback = request.getParameter("callback");
	String worker_id = request.getParameter("worker_id") == null ? "" : request.getParameter("worker_id");
	String worker_name = request.getParameter("worker_name") == null ? "" : request.getParameter("worker_name");
    String id = request.getParameter("id") == null ? "" : request.getParameter("id");
    boolean isAdd = "".equals(id);
    int flag = 0;
    if(!isAdd){
    	flag = 1;
    }
%>

<html>
	<head>
		<title><%=isAdd?"新建分包记账单":"编辑分包记账单" %></title>
		<style>
			.td1{
				padding-top:10px;
				padding-bottom:5px;
				font-size: 12px;
				background-color: #c0ebd7;
				width:20%;
			}
			.td2{
				padding:5px;
			}
			.tdg{
			padding-top:10px;
			padding-bottom:5px;
			font-size: 12px;
			background-color: #c0ebd7;
			width:20%;
		}
		.tdb{
			padding:5px;
			width:30%;
		}
		</style>
	</head>
	<script type="text/javascript">	
		var flag = '<%=flag%>';
		$(function(){
			<%=isAdd?"":"jQuery('#ff').form('load','"+contextPath+"/springMVC/crm/getAccountingById?id="+id+"');"%>
			jQuery("#type_id").combotree({
				url:'<%=contextPath %>/springMVC/group/getSystemTypeTree?type=11',
				method:'POST',
				animate:true,
				lines:true
			});
		});
		
		function doSubmit(obj){
			var type_id = jQuery("#type_id").combotree('getValue');
			var remark =jQuery("#remark").val();
			var money=jQuery("#money").numberbox('getValue');
			var operation_time=jQuery("#operation_time").datebox('getValue');
			var param = "type_id="+type_id+"&remark="+remark+"&money="+money+"&operation_time="+operation_time+"&worker_id=<%=worker_id%>&worker_name=<%=worker_name%>";
			$(obj).hide();
				$.ajax({
					type:'POST',
					<%=isAdd?"url:'"+contextPath+"/springMVC/crm/addAccounting',":"url:'"+contextPath+"/springMVC/crm/updateAccounting?id="+id+"',"%>
					data:param,
					success:function(rtJson){
						if (rtJson.rtState == '0'){
							eval('window.opener.<%=callback%>();');
							window.close();
						}else{
							$(obj).show();
							warningInfo(rtJson.rtMsrg);
						}
					}
				});
			}
		
	</script>
	<body>
		<form id="ff" method="post">
		<div style="width:90%;padding-left:50px;margin-top:50px">
			<table  style="border-collapse: collapse;" width="100%" border="1px" bordercolor="#0eb83a">
				<tr>
					<td align="right"  nowrap class="td1">
						分类：
					</td>
					<td class="td2" nowrap>
						<input  id="type_id" name="type_id" class="easyui-combotree"  data-options="required:true">
					</td>
				</tr>
				<tr>
					<td align="right"  nowrap class="td1">
						分包商名称：
					</td>
					<td class="td2" nowrap >
						<input type="text" id="worker_name" name="worker_name" value="<%=worker_name %>" class="easyui-validatebox" disabled="disabled" >
					</td>
				</tr>
				<tr>
					<td align="right"  nowrap class="td1">
						记账金额：
					</td>
					<td class="td2" nowrap >
						<input  id="money" name="money" class="easyui-numberbox"  data-options="disabled:false,precision:2"/>
					</td>
				</tr>
					<tr>
					<td align="right"  nowrap class="td1">
						记账时间：
					</td>
					<td class="td2" nowrap >
						<input  id="operation_time" name="operation_time" class="easyui-datebox"/>
					</td>
				</tr>
				<tr>
					<td align="right"  nowrap class="td1">
						记账原因：
					</td>
					<td class="td2" nowrap >
					<textarea  id="remark" name="remark" rows="6" style="width: 100%"></textarea>
					</td>
				</tr>
				
				
				<tr>
					<td align="right" nowrap class="td1">
					</td>
					<td  nowrap colspan="5">
						<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-save',plain:false" onclick="doSubmit(this);">保存</a>
						<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-cancel',plain:false" onclick="javascript:window.close();">关闭</a>
					</td>
				</tr>
				
 			</table>
		</div>
		</form>
	</body>
</html>
